/**
 * Created by xs on 2017/12/27.
 */
(function () {
    angular.module('app')
        .component('xxPersonInfo',{
            templateUrl:'./app/user/person-info/person-info.html',
            controller:ctrl
        });
    function ctrl($scope,$state,$stateParams,PersonInfoFactory,userService) {
        $scope.personInfo = [];
        $scope.personInfo['asset'] = userService['asset'];

        var username = $stateParams.username;
        function getPersonInfo(username) {
            function cb(err,res) {
                if (!err){
                    $scope.personInfo = res['res'];
                    var d = new Date(res['res']['birthday']);
                    var num = d.getTime();
                    var dd = new Date(num);
                    dd.getFullYear();
                    dd.toString();
                    $scope.personInfo.birthday = dd.getFullYear() + '-' + (dd.getMonth()+1) + '-' + dd.getDate();
                    //console.log('test',dd,$scope.personInfo);
                }

            }
            PersonInfoFactory.getPersonInfo(username,cb);
        }
        getPersonInfo(username);

        $scope.recharge = function (username) {
            $state.go('show.recharge',{'username':username});
        }
    }
})();

